package com.ruoyi.system.service.impl;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.CustomLogMapper;
import com.ruoyi.system.domain.CustomLog;
import com.ruoyi.system.service.ICustomLogService;
import com.ruoyi.common.core.text.Convert;

/**
 * custom日志Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-05-10
 */
@Service
public class CustomLogServiceImpl implements ICustomLogService 
{
    @Autowired
    private CustomLogMapper customLogMapper;

    /**
     * 查询custom日志
     * 
     * @param id custom日志主键
     * @return custom日志
     */
    @Override
    public CustomLog selectCustomLogById(String id)
    {
        return customLogMapper.selectCustomLogById(id);
    }

    /**
     * 查询custom日志列表
     * 
     * @param customLog custom日志
     * @return custom日志
     */
    @Override
    public List<CustomLog> selectCustomLogList(CustomLog customLog)
    {
        customLog.setCaozuoren("%"+customLog.getCaozuoren()+"%");
        customLog.setDanweimingcheng("%"+customLog.getDanweimingcheng()+"%");
        return customLogMapper.selectCustomLogList(customLog);
    }

    /**
     * 新增custom日志
     * 
     * @param customLog custom日志
     * @return 结果
     */
    @Override
    public int insertCustomLog(CustomLog customLog)
    {
        return customLogMapper.insertCustomLog(customLog);
    }

    /**
     * 修改custom日志
     * 
     * @param customLog custom日志
     * @return 结果
     */
    @Override
    public int updateCustomLog(CustomLog customLog)
    {
        return customLogMapper.updateCustomLog(customLog);
    }

    /**
     * 批量删除custom日志
     * 
     * @param ids 需要删除的custom日志主键
     * @return 结果
     */
    @Override
    public int deleteCustomLogByIds(String ids)
    {
        return customLogMapper.deleteCustomLogByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除custom日志信息
     * 
     * @param id custom日志主键
     * @return 结果
     */
    @Override
    public int deleteCustomLogById(String id)
    {
        return customLogMapper.deleteCustomLogById(id);
    }

    @Override
    public List<Map<String,Object>>findcustomlog(String ppDanweimingcheng, String ppJigoujibie, String ppDiqu, int ppPageIndex,int ppPageSize){
        int mmStartIndex = (ppPageIndex - 1) * ppPageSize;

        if (!ppDanweimingcheng.equals("")){
            ppDanweimingcheng = "%"+ppDanweimingcheng+"%";
        }
        if (!ppDiqu.equals("")){
            ppDiqu = "%"+ppDiqu+"%";
        }

        return customLogMapper.findcustomlog(ppDanweimingcheng,ppJigoujibie,ppDiqu,mmStartIndex,ppPageSize);
    }

    public int countcustomlog(String ppDanweimingcheng,String ppJigoujibie,String ppDiqu){

        if (!ppDanweimingcheng.equals("")){
            ppDanweimingcheng = "%"+ppDanweimingcheng+"%";
        }
        if (!ppDiqu.equals("")){
            ppDiqu = "%"+ppDiqu+"%";
        }

        return customLogMapper.countcustomlog(ppDanweimingcheng,ppJigoujibie,ppDiqu);
    }
}
